var show_status = document.getElementById("show_status");
function show(text){
    show_status.innerText = text;
}

var input_username = document.getElementById("name")
var input_password = document.getElementById("password")

document.getElementById("close").onclick = function () {
        jump();
};

document.getElementById("submit").onclick = function () {
    var username = input_username.value
    var password = input_password.value

    if(is_empty(username)){
        show("请输入用户名")
        return
    }
    if(is_empty(password)){
        show("请输入密码")
        return
    }
    api_register(username, password, function (data){
        if(data['code'] === 1){
            alert("注册成功")
            jump()
        }else{
            show(data['msg'])
        }
    })
};

function jump(){
    var jump_url = new URL(window.location.href).searchParams.get('jump')
    if(is_empty(jump_url)){
        window.close()
    }else{
        location.replace(jump_url)
    }
}